import React,{ Component } from 'react';
import './closing.scss';
import { 
	Link
} from 'react-router-dom';
import { expectList } from 'api/client.js';
export default class Closing extends Component{
	constructor (props) {
		super(props)
		this.state={
			closingList: []
		}
	}
	_expectList () {
		expectList({
			employee_id: 10000,
			order_by: this.props.orderBy
		}).then(res => {
			if(res.code === 1){
				this.setState({
					closingList: res.data
				})
			}
		})
	}
	componentDidMount () {
		this._expectList()
		
	}
	componentWillReceiveProps(){
		this.setState({
			closingList: []
		},()=>{
			this._expectList()
		})
	}
	render(){
		return(
			<div className="closing">
				<div className="closing_num">共{this.state.closingList.length}名客户</div>
				{
					this.state.closingList.map((item,index) => {
						return(
							<Link to={
								{
									pathname: `${window.baseUrl}/clinetDetails`,
									state: {
										account_user_id: item.account_user_id
									}
								}
							} key={index}><div className="closing_list">
								<div className="closing_left">
									<img src={item.wx_avatar} className="closing_img" alt="lalal"/>
									<div className="closing_title">
										<p>{item.account_note}</p>
										<span>来源：{item.account_source}</span>
									</div>
								</div>
								<div className="closing_right">
									<p>AI成交率: <span className="num_zhi">{item.employee_expect_closing}%</span></p>
									<span>{item.update_at === 0 ? '未跟进过' : item.update_at+'天跟进过'}</span>
								</div>
							</div></Link>
						)
					})
				}
			</div>
		)
	}
}